function EPSPvsPosition(Connection)
% plot the relationship between EPSP amplitude and cell positions. cf.
% cellDistributionAnalysis.m and finalsummary.m
% run this fcn after using finalsummary.m

addpath('C:\Data\Taro\ANALYSIS\multi_rec_project\striatal2spinal')
list = list_St2Sp;

AmpPos = zeros(length(list),3);

% the following code assumes cell num of list and Connection coincide.
for cellnum = 1:length(list)
    [pathstr, name, ext, versn] = fileparts(list(cellnum).filename);
    cd(pathstr)
    load cellDist

    % find the index of connection.
    ind = bsxfun(@minus,PrePost_all, list(cellnum).pre2post);
    ind = sum(abs(ind),2);
    ind = find(ind == 0);

    % put together r, theta and EPSP amplitude.
    AmpPos(cellnum,1) = theta_all(ind);
    AmpPos(cellnum,2) = r_all(ind);
    AmpPos(cellnum,3) = Connection(cellnum).firstEPSPamp;
end

% plot r, theta and EPSP amplitude
figure;
polar(0,300)
hold on
colorInt = jet(64);
colorMax = max(AmpPos(:,3));
for cellnum = 1:length(list)
    fillColor = round(AmpPos(cellnum,3)/colorMax * 64);
    [x y] = pol2cart(AmpPos(cellnum,1),AmpPos(cellnum,2));
    scatter(x,y,'MarkerFaceColor',colorInt(fillColor,:),'MarkerEdgeColor','w')
    hold on
end

colorbar('YTick',[0;1],'YTickLabel',{'0',num2str(colorMax)})
ylim([0 300])
